﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Toast.Core;
using Toast.Core.Interfaces;

namespace Toast.Extensions
{
    public static class CompressionDictionaryExtensions
    {
        public static ICompressionStrategy ForJavaScript(this DefaultCompressionDictionary dictionary)
        {
            return dictionary.For<IJavaScriptContent>();
        }

        public static ICompressionStrategy ForCss(this DefaultCompressionDictionary dictionary)
        {
            return dictionary.For<ICssContent>();
        }

        public static void DefaultForJavaScriptIs<TCompress>(this DefaultCompressionDictionary dictionary) where TCompress : IJavaScriptCompressionStrategy, new()
        {
            dictionary.SetDefaultFor<IJavaScriptContent, TCompress>();
        }       
        
        public static void DefaultForJavaScriptIs<TCompress>(this DefaultCompressionDictionary dictionary, CompressionLevel compressLevel) where TCompress : IJavaScriptCompressionStrategy, new()
        {
            dictionary.SetDefaultFor<IJavaScriptContent, TCompress>(compressLevel);
        }

        public static void DefaultForCssIs<TCompress>(this DefaultCompressionDictionary dictionary) where TCompress : ICssCompressionStrategy, new()
        {
            dictionary.SetDefaultFor<ICssContent, TCompress>();
        }

        public static void DefaultForCssIs<TCompress>(this DefaultCompressionDictionary dictionary, CompressionLevel compressLevel) where TCompress : ICssCompressionStrategy, new()
        {
            dictionary.SetDefaultFor<ICssContent, TCompress>(compressLevel);
        }
    }
}
